<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8" %>
<%@ include file="/cms/include/init_admin.jsp" %>
<%@ page import="com.qbooks.cms.admin.*" %>
<%
	HashList code002	= CommonUtil.getCodeList("002");	//광고모듈
	HashList code019	= CommonUtil.getCodeList("019");	//판매자구분
	HashList codeUseYn	= CommonUtil.getCodeList("use_yn");	//

	String job_type		= StringUtil.nvl(request.getParameter("job_type"),"U");
	String app_id	= StringUtil.nvl(request.getParameter("app_id"));

	HashMap infos 		= new HashMap();
	infos.put("app_id",	app_id);

	AdminDAO dao 		= new AdminDAO();
	HashList list 		= dao.selectAppList(infos);
	HashList hisList	= dao.selectAppHistoryList(infos);	

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title><%= SYSTEM_NAME %></title>
	<%@ include file="/cms/include/cssnjs.jsp"  %>
	<script type="text/javascript" src="/js/ajaxfileupload.js"></script>
	<script type="text/javascript" src="/SE2.3.1.O9858/js/HuskyEZCreator.js" charset="utf-8"></script>

	<script type="text/javascript">
	var oEditors = [];

	$(document).ready(function() {

		/* 탭 클릭 */
		$('li', '#tabs').click(function(){
		    $('.on', '#tabs').removeClass('on').addClass('off');
		    $(this).addClass('on');

			$('#tabs-1:not(.hidden),#tabs-2:not(.hidden),#tabs-3:not(.hidden)').addClass('hidden');
			$('#tabs-'+$(this).attr('code')).removeClass('hidden');
		});

		$('#list').find('input').change(function() {
			$(this).closest('tr').find('input[name="list.job_type"]').val('U');
		});

	});


	function fnSave() {
		if (confirm(MSG_<%=job_type%>)) {
			$('#saveForm').attr('action', './appSave.do');
			$('#saveForm').submit();
		}
	}


	function fnDelete() {
		if (confirm(MSG_D)) {
			$('#job_type').val('D');
			$('#saveForm').attr('action', './appSave.do');
			$('#saveForm').submit();
		}
	}

	function fnNew() {
		cfOpen('./appHistoryDetail.jsp?app_id=<%=app_id%>&history_seq=', '업데이트 이력 상세', 600, 400);
	}

	function fnHistoryDetail(history_seq) {
		cfOpen('./appHistoryDetail.jsp?app_id=<%=app_id%>&history_seq='+history_seq, '업데이트 이력 상세', 600, 400);
	}
	</script>
</head>
<body>
<div id="wrap">
	<div id="top">
		<%@ include file="/cms/include/top.jsp" %>
	</div>
	<div id="page">
		<div id="menu">
			<%@ include file="/cms/include/leftMenu.jsp" %>
		</div>
		<div id="contents">
			<div class="menu_title">
				<h1>앱관리</h1>
				<p>CMS > 관리자  > <b>앱관리</b></p>
			</div>
			<div class="clear line_01"></div>

			<ul id="tabs" class="tab_01 mt15">
			    <li class="on"  code="1"><p>1. 기본사항</p></li>
		<%	if ("U".equals(job_type)) { %>
			    <li   code="2"><p>2. 업데이트이력</p></li>
		<%	} %>
			</ul>

			<div id="tabs-1" class="mt15">
				<form name="frm" id="saveForm" method="post" action="">
				<input type="hidden" name="job_type" id="job_type" value="<%= job_type %>"/>
				

				<table cellpadding="0" cellspacing="0" class="table_01 mt5">
				<colgroup>
					<col width="100px"/>
					<col width="300px"/>
					<col width="100px"/>
					<col/>
				</colgroup>
				<tbody>
					<tr>
						<th><p>아이디</p></th>
						<td colspan="3" class="brx">
						<%	if ("U".equals(job_type)) { %>
							<input type="hidden" name="app_id" value="<%= list.get("app_id", 0) %>" />
							<%= list.get("app_id", 0) %>
						<%	} else { %>
							<input type="text" name="app_id" value="<%= list.get("app_id", 0) %>" maxlength="12" class="w200"/>
						<%	} %>
						</td>
					</tr>
					<tr>
						<th><p>앱명</p></th>
						<td colspan="3" class="brx">
		        			<input type="text" name="app_name" value="<%= list.get("app_name", 0) %>"  class="wmax"/>
						</td>
					</tr>
					<tr>
						<th><p>버전</p></th>
						<td>
							<input type="text" name="version" value="<%= list.get("version", 0) %>" class="w200"/>
						</td>
						<th><p>OS</p></th>
						<td class="brx">
		        			<%= StringUtil.makeRadio(code019, "os_type", list.get("os_type",0)) %>
						</td>
					</tr>
					<tr>
						<th><p>업데이트URL</p></th>
						<td colspan="3" class="brx">
							<input type="text" name="update_url" value="<%= list.get("update_url", 0) %>" class="wmax"/>
						</td>
					</tr>
					<tr>
						<th><p>광고</p></th>
						<td >
							<%= StringUtil.makeRadio(code002, "ad_code", list.get("ad_code",0)) %>
						</td>
						<th><p>다운로드</p></th>
						<td  class="brx">
							<%= list.get("download_count", 0) %>
	        			</td>
					</tr>
					<tr>
						<th><p>공지사항</p></th>
						<td colspan="3" class="brx">
							<textarea name="notice" rows="10" class="wmax"><%= list.get("notice", 0) %></textarea>
						</td>
					</tr>
					<tr>
						<th><p>공지사항 URL</p></th>
						<td colspan="3" class="brx">
							<input type="text" name="notice_url" value="<%= list.get("notice_url", 0) %>" class="wmax"/>
						</td>
					</tr>
					<tr>
						<th><p>등록일</p></th>
						<td>
							<%= list.get("init_date", 0) %>
						</td>
						<th><p>사용여부</p></th>
						<td class="brx">
							<%= StringUtil.makeRadio(codeUseYn, "use_yn", list.get("use_yn",0)) %>
						</td>
					</tr>
				</tbody>
				</table>


				<div class="mt20 mb10 c">
					<a href="./appList.jsp"><img src="../images/btn_list.gif"/></a>
			<%	if ("U".equals(job_type)) { %>
					<a href="#nohref" onclick="fnSave()"><img src="../images/btn_update.gif" /></a>
					<a href="#nohref" onclick="fnDelete()"><img src="../images/btn_delete.gif" /></a>
			<%	} else if ("C".equals(job_type)) { %>
					<a href="#nohref" onclick="fnSave()"><img src="../images/btn_register.gif" /></a>
			<%	} %>
				</div>

				</form>

			</div>

			<div id="tabs-2" class="mt15 hidden">
				<table cellpadding="0" cellspacing="0" class="table_01 mt5">
				<colgroup>
					<col width="100px"/>
					<col/>
					<col width="100px"/>
					<col width="100px"/>
				</colgroup>
				<tbody>
					<tr>
						<th><p>버전</p></th>
						<th><p>설명</p></th>
						<th><p>다운로드</p></th>
						<th class="brx"><p>사용여부</p></th>
					</tr>
			<%	for (int i = 0; i < hisList.size(); i++) { %>
					<tr>
						<td class="c"><a href="#nohref" onclick="fnHistoryDetail('<%= hisList.get("history_seq",i) %>')"><%= hisList.get("version",i) %></a></td>
						<td><%= hisList.get("remarks",i) %></td>
						<td class="c"><a href="<%= hisList.get("download_url",i) %>">[다운로드]</a></td>
						<td class="c brx"><%= hisList.get("use_yn",i) %></td>
					</tr>
			<%	} %>
			
					
				</tbody>
				</table>

				<div class="mt20 mb10 c">
					<a href="./appList.jsp"><img src="../images/btn_list.gif"/></a>
					<a href="#nohref" onclick="fnNew()"><img src="../images/btn_new.gif"/></a>
				</div>
				

			</div>



		</div>
	</div>
</div>

</body>
</html>
